﻿using EYWeb.Core;
using EYWeb.Domain.Entities;
using EYWeb.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EYWeb.Services
{
    public class LogService : BaseService<LogEntity>, ILogService
    {
        private readonly ILogRepository _logRepository;

        public LogService(ILogRepository logRepository):base(logRepository)
        {
            _logRepository = logRepository;
        }

        public void WriteDbLog(LogEntity logEntity)
        {
            logEntity.Id = Guid.NewGuid().ToString();
            logEntity.Date = DateTime.Now;
            logEntity.IPAddress = Net.Ip;
            logEntity.IPAddressName = Net.GetLocation(logEntity.IPAddress);
            _logRepository.Insert(logEntity);
        }
    }
}
